﻿namespace UnitTest_MSTestHelper
{
    using System.Linq;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Collections.Generic;
    using System;

    [TestClass]
    public class When_running_multiple_tests_with_TestRunner
    {
        [TestMethod]
        public void Runs_all_the_tests_if_non_fail()
        {
            var testsRun = new List<string>();
            new string[]
            {
                "A",
                "B"
            }
            .Run(value => testsRun.Add(value));

            AssertEx.That(() => testsRun.SequenceEqual(new string[] { "A", "B" }));
        }

        [TestMethod]
        public void First_test_to_be_inconclusive_stops_and_returns_inconclusive_using_args()
        {
            AssertEx.Throws<AssertInconclusiveException>(
                () =>
                {
                    new string[]
                    {
                        "A",
                        "B"
                    }
                    .Run(value => Assert.Inconclusive("MESSAGE"));
                });
        }

        [TestMethod]
        public void First_test_to_be_inconclusive_stops_and_returns_inconclusive_using_ListItemCollection()
        {
            AssertEx.Throws<AssertInconclusiveException>(
                () =>
                {
                    ListBuilder<string>
                        .AddItem("A")
                        .AddItem("B")
                        .Run(value => Assert.Inconclusive("MESSAGE"));
                });
        }
    }
}